
/**
 * @author Patrick
 *
 */
public class BooleanOp extends Operator{
	public BooleanOp(String newOp) {
		super(newOp);
	}
	
	@Override
	public boolean isBooleanOp() {
		return true;
	}
	
	@Override
	public STO checkOperands(STO left, STO right) {
		if (left.isError()) { 
			return left;
		}
		if (right.isError()){
			return right;
		}
		STO sto = null;
		Type l_type = left.getType();
		Type r_type = right.getType();
		// both operand types must be numeric, otherwise throw error
		if ((l_type.isBool() && r_type.isBool())){
			if(left.isConst() && right.isConst()) {
				sto = new ConstSTO("And/Or result", new BoolType());
			}
			else {
				if(!left.isConst()) {
					sto = new ExprSTO(left.getName(), new BoolType());
				}
				else {
					sto = new ExprSTO(right.getName(), new BoolType());
				}
			}
		}
		else {
			sto = new ErrorSTO("error1w_Expr");
		}
		return sto;
	}
}
